import cgi

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import mail

class Feedback(webapp.RequestHandler):
    def post(self):

        #send a thank you to the user
        name = self.request.get('name')
        email = self.request.get('email')
        comment = self.request.get('comment')
        message = mail.EmailMessage(sender="L.A.B. Feedback <feedback@linuxappliancebox.appspotmail.com>",
                            subject="Thank you for your feedback")

        message.to = email
        message.body = """
Thank you %s for your comments.

You wrote:
%s
        """ % (name, comment)

        message.send()

        #send to the feedback system
        message = mail.EmailMessage(sender="L.A.B. Feedback <feedback@linuxappliancebox.appspotmail.com>",
                            subject="feedback")
        message.to = "feedback@linuxappliancebox.com"
        message.body = """
%s
%s
%s
        """ % (name, email, comment)
        message.send()

        self.response.out.write('Thanks you<b> ' + name + ' </b>for your comments')


application = webapp.WSGIApplication(
                                     [('/feedback', Feedback)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
